package ctxdata

import (
	"context"
	"encoding/json"
	"strconv"
)

// CtxKeyJwtUserId get uid from ctx
var CtxKeyJwtUserId = "id"
var CtxKeyJwtIdentify = "id"

func GetUidFromCtx(ctx context.Context) int64 {
	uid, _ := ctx.Value(CtxKeyJwtUserId).(json.Number).Int64()
	return uid
}

func GetIdentityFromCtx(ctx context.Context) int64 {
	identify, _ := ctx.Value(CtxKeyJwtIdentify).(json.Number).Int64()
	return identify
}

func GetAuthIdentity(ctx context.Context) string {
	uid := GetUidFromCtx(ctx)
	identify := GetIdentityFromCtx(ctx)
	return strconv.Itoa(int(uid)) + "-" + strconv.Itoa(int(identify))
}
